import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import weekOfYear from 'dayjs/plugin/weekOfYear';

import 'dayjs/locale/zh-cn';
import { DEFAULT_TIMEZONE } from '~/modules/lang/times';
import { BootstrapContext } from '~/plugins/models';

export const setup = (context: BootstrapContext): Promise<void> => {
  dayjs.extend(duration);
  dayjs.extend(utc);
  dayjs.extend(timezone);
  dayjs.extend(weekOfYear);
  dayjs.locale('zh-cn');
  dayjs.tz.setDefault(DEFAULT_TIMEZONE);
  return Promise.resolve();
};
